﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ADShop.Models;

namespace ADShop.Controllers
{
    public class StatusProductController : Controller
    {
        private EShopEntities1 db = new EShopEntities1();// ADShopEntities db = new ADShopEntities();

        //
        // GET: /StatusProduct/

        public ActionResult Index()
        {
            return View(db.StatusProduct.ToList());
        }

        //
        // GET: /StatusProduct/Details/5

        public ActionResult Details(int id = 0)
        {
            StatusProduct statusproduct = db.StatusProduct.Find(id);
            if (statusproduct == null)
            {
                return HttpNotFound();
            }
            return View(statusproduct);
        }

        //
        // GET: /StatusProduct/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /StatusProduct/Create

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create(StatusProduct statusproduct)
        {
            if (ModelState.IsValid)
            {
                db.StatusProduct.Add(statusproduct);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(statusproduct);
        }

        //
        // GET: /StatusProduct/Edit/5

        public ActionResult Edit(int id = 0)
        {
            StatusProduct statusproduct = db.StatusProduct.Find(id);
            if (statusproduct == null)
            {
                return HttpNotFound();
            }
            return View(statusproduct);
        }

        //
        // POST: /StatusProduct/Edit/5

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit(StatusProduct statusproduct)
        {
            if (ModelState.IsValid)
            {
                db.Entry(statusproduct).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(statusproduct);
        }

        //
        // GET: /StatusProduct/Delete/5

        public ActionResult Delete(int id = 0)
        {
            StatusProduct statusproduct = db.StatusProduct.Find(id);
            if (statusproduct == null)
            {
                return HttpNotFound();
            }
            return View(statusproduct);
        }

        //
        // POST: /StatusProduct/Delete/5

        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            StatusProduct statusproduct = db.StatusProduct.Find(id);
            db.StatusProduct.Remove(statusproduct);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}